//
//  GCMGZRHTableViewCell.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/8/10.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMGZRHTableViewCell.h"

@implementation GCMGZRHTableViewCell{
    UIView *_bgView;
    UILabel *_dataLabel;
    UIView *_contentLabel;
    UILabel *_numberLabel;
    UILabel *_swLabel;
    UILabel *_xwLabel;
    UILabel *_shrLabel;
    

}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        [self createUI];
    }
    return self;
}

-(void)createUI1{
//    self.contentView.backgroundColor = [UIColor redColor];
    
    _bgView = [[UILabel alloc]init];
    _bgView.frame =CGRectMake(0, 1,SCREEN_WIDTH,51);
//    _bgView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_bgView];
    
    _dataLabel = [[UILabel alloc]init];
    _dataLabel.frame =CGRectMake(0, 0,(_bgView.bounds.size.width- 2)/3,50);
    _dataLabel.backgroundColor = [UIColor whiteColor];
    _dataLabel.textAlignment = NSTextAlignmentCenter;
    _dataLabel.font = [UIFont systemFontOfSize:16];
    [_bgView addSubview:_dataLabel];
    
    _swLabel = [[UILabel alloc]init];
    _swLabel.frame = CGRectMake((_bgView.bounds.size.width- 2)/3+1 ,0,(_bgView.bounds.size.width- 2)/3, 50);
    _swLabel.font = [UIFont systemFontOfSize:15];
    _swLabel.backgroundColor = [UIColor whiteColor];
    _swLabel.textAlignment = NSTextAlignmentCenter;
    [_bgView addSubview:_swLabel];

    _shrLabel = [[UILabel alloc]init];
    _shrLabel.frame = CGRectMake((_bgView.bounds.size.width- 2)/3*2 +2 ,0,(_bgView.bounds.size.width- 2)/3, 50);
    _shrLabel.font = [UIFont systemFontOfSize:15];
    _shrLabel.backgroundColor = [UIColor whiteColor];
    _shrLabel.textAlignment = NSTextAlignmentCenter;
    [_bgView addSubview:_shrLabel];
    
}

-(void)createUI2{
    //    self.contentView.backgroundColor = [UIColor redColor];
    
    _bgView = [[UILabel alloc]init];
    _bgView.frame =CGRectMake(0, 1,SCREEN_WIDTH,51);
    //    _bgView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_bgView];
    
    _dataLabel = [[UILabel alloc]init];
    _dataLabel.frame =CGRectMake(0, 0,(_bgView.bounds.size.width- 3)/4,50);
    _dataLabel.backgroundColor = [UIColor whiteColor];
    _dataLabel.textAlignment = NSTextAlignmentCenter;
    _dataLabel.font = [UIFont systemFontOfSize:16];
    [_bgView addSubview:_dataLabel];
    
    _swLabel = [[UILabel alloc]init];
    _swLabel.frame = CGRectMake((_bgView.bounds.size.width- 3)/4+1 ,0,(_bgView.bounds.size.width- 3)/4, 50);
    _swLabel.font = [UIFont systemFontOfSize:15];
    _swLabel.backgroundColor = [UIColor whiteColor];
    _swLabel.textAlignment = NSTextAlignmentCenter;
    [_bgView addSubview:_swLabel];
    //
    _xwLabel = [[UILabel alloc]init];
    _xwLabel.frame = CGRectMake((_bgView.bounds.size.width- 3)/4*2 +2 ,0,(_bgView.bounds.size.width- 3)/4, 50);
    _xwLabel.font = [UIFont systemFontOfSize:15];
    _xwLabel.backgroundColor = [UIColor whiteColor];
    _xwLabel.textAlignment = NSTextAlignmentCenter;
    [_bgView addSubview:_xwLabel];
    
    _shrLabel = [[UILabel alloc]init];
    _shrLabel.frame = CGRectMake((_bgView.bounds.size.width- 3)/4*3 +3 ,0,(_bgView.bounds.size.width- 3)/4, 50);
    _shrLabel.font = [UIFont systemFontOfSize:15];
    _shrLabel.backgroundColor = [UIColor whiteColor];
    _shrLabel.textAlignment = NSTextAlignmentCenter;
    [_bgView addSubview:_shrLabel];
    
    
}

-(void)setDic:(NSDictionary *)dic{

    NSDictionary *dict = [[NSDictionary alloc]init];
    dict  = dic;
    NSLog(@"%@",dict);
    
    if ([[dict valueForKey:@"type"] isEqualToString:@"一天一次"]) {
        
        [self createUI1];
        
        _dataLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"riqi"]];
        _dataLabel.font = [UIFont systemFontOfSize:13];
        _swLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"s_heji"]];
        _xwLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"x_heji"]];
        if ([[NSString stringWithFormat:@"%@",[dic valueForKey:@"s_heji"]] isEqualToString:@"0"]) {
            
            _shrLabel.text = @"未打分";
            _shrLabel.textColor = [UIColor redColor];
        }else{
            
            _shrLabel.text = @"已打分";
            _shrLabel.textColor = [UIColor colorWithRed:0.11 green:0.68 blue:0.59 alpha:1.0];
        }
        
    }else{
    
        [self createUI2];
        _dataLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"riqi"]];
        _dataLabel.font = [UIFont systemFontOfSize:13];
        _swLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"s_heji"]];
        _xwLabel.text = [NSString stringWithFormat:@"%@",[dic valueForKey:@"x_heji"]];
        if ([[NSString stringWithFormat:@"%@",[dic valueForKey:@"s_heji"]] isEqualToString:@"0"]) {
            
            _shrLabel.text = @"编辑";
            _shrLabel.textColor = [UIColor redColor];
        }else{
            
            _shrLabel.text = @"修改";
            _shrLabel.textColor = [UIColor colorWithRed:0.11 green:0.68 blue:0.59 alpha:1.0];
        }
    }

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

